#ifndef __DB_INTERFACE_HPP__
#define __DB_INTERFACE_HPP__
#include "type_define.hpp"
#include "net_interface.hpp"

const LIBVERSION  p2p_client_libversion = MAKEVERSION(1, 0, 0, 0);

class IP2PSessionManager
{
public:
    virtual void OnLogin(INT32 err_code, UINT32 p2p_id) = 0;
    virtual void OnOpen(UINT32 peer_p2p_id) = 0;
    virtual void OnData(UINT32 peer_p2p_id, const char* data, const INT32 data_len) = 0;
    virtual void OnError(UINT32 peer_p2p_id, INT32 err_code) = 0;
    virtual void OnClose(UINT32 peer_p2p_id) = 0;
protected:
private:
};

class IP2P
{
public:
    virtual bool Login(const char* p2p_server_ip, const UINT16 p2p_server_port, const UINT16 p2p_nat_test_port) = 0;
    virtual bool AddPeer(UINT32 peer_p2p_id) = 0;
    virtual void DelPeer(UINT32 peer_p2p_id) = 0;
    virtual bool SendPeer(UINT32 peer_p2p_id, const char* pData, const INT32 iLen) = 0;
    virtual void SetPeerUserData(UINT32 peer_p2p_id, void* user_data) = 0;
    virtual void* GetPeerUserData(UINT32 peer_p2p_id) = 0;
    virtual bool Run(void) = 0;
};

IP2P* CreateP2PClient(IP2PSessionManager* p2p_session_manager, LIBVERSION libversion = p2p_client_libversion);
typedef IP2P* (*pfn_CreateP2PClient)(IP2PSessionManager* p2p_session_manager, LIBVERSION libversion);

#endif